// merchants/verifications/index.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) { //cardId:折扣卡id,couponInfo
    let params = decodeURIComponent(options.scene);
    if (params && params != 'undefined') {//扫描小程序二维码进入
      let plist = '';
      if (params.indexOf('-') != -1) {
        let param = params.match(/p-(\S*)/)[1];//参数
        plist = param.split('_');
        if (params.indexOf('t-') != -1) {//会员折扣卡
          wx.setStorageSync('cardId', plist[3]);
          wx.redirectTo({
            url: '../verifications/index?creatUid=' + plist[0] + '&userid=' + plist[1] + '&cardId=' + plist[2] + '&cardid=' + plist[3],
          })
        } else {//优惠券
          wx.setStorageSync('cardId', plist[3]);
          wx.redirectTo({
            url: '../verifications/index?userid=' + plist[0] + '&coupontypeid=' + plist[1] + '&couponid=' + plist[2] + '&cardid=' + plist[3],
          })
        }
      } else {
        let param = params.match(/p=(\S*)/)[1];//参数
        plist = param.split('#');
        if (params.indexOf('t=') != -1) {//会员折扣卡
          wx.setStorageSync('cardId', plist[3]);
          wx.redirectTo({
            url: '../verifications/index?creatUid=' + plist[0] + '&userid=' + plist[1] + '&cardId=' + plist[2] + '&cardid=' + plist[3],
          })
        } else {//优惠券
          wx.setStorageSync('cardId', plist[3]);
          wx.redirectTo({
            url: '../verifications/index?userid=' + plist[0] + '&coupontypeid=' + plist[1] + '&couponid=' + plist[2] + '&cardid=' + plist[3],
          })
        }
      }
    }
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  }
})